<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <script src="vue.js"></script>
  <script src="vue-router.js"></script>
</head>
<body>
  <div id="app">
    <router-link to="/user/10/admin">登录</router-link>
    <router-view></router-view>
  </div>
  <script>
    // 定义user组件 
    var user = {
      template: '<h3>id: {{$route.params.id}} ' + 
      'name: {{$route.params.name}}</h3>',
      created () {				      	// 组件的生命周期钩子函数
        console.log(this.$route)	// 用this.$route来接收参数
      }
    }
    var router = new VueRouter({
      routes: [
        { path: '/user/:id/:name', component: user }
      ]
    })
    var vm = new Vue({ el: '#app', router })
  </script>
</body>
</html>